const a = new Promise((resolve, reject) => {
  console.log(`111`)
  setTimeout(() => {
    resolve(123)
  },2000)
})

a.then((data) => {
  console.log(data)
})

class MyPromise {
  constructor (fn){
    const resolve = successVal => {
      this.successVal = successVal
    }
    fn(resolve)
  }
  then(successFn){
    successFn(this.successVal)
  }
}

const b = new MyPromise((resolve, reject) => {
  console.log(`111`)
  setTimeout(() => {
    resolve(123)
  },2000)
})

b.then((data) => {
  console.log(data)
})
